package stringbuilderdemo;

public class StringBuilderDemo1 {
    public static void main(String[] args) {
       /* StringBuilder sb = new StringBuilder("abc");*/

       /* //增加元素
        sb.append(2);
        sb.append(3.14);
        sb.append(false);*/

        //反转
       /* sb.reverse();

        int len = sb.length();
        System.out.println(len);

        System.out.println(sb);*/

        StringBuilder sb = new StringBuilder();

        //添加字符串
        /*sb.append("aaa");
        sb.append("bbb");
        sb.append("ccc");
        sb.append("ddd");*/

        //链式编程
        sb.append("aaa").append("bbb").append("ccc").append("ddd");

        System.out.println(sb);

        //3.再把StringBuilder变回字符串
        String str = sb.toString();
        System.out.println(str);
    }
}
